package info.nene_loveplus.controller.api;

import info.nene_loveplus.util.WikiUtil;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.controller.validator.RequiredValidator;
import org.slim3.controller.validator.Validators;

public class WikiHtmlController extends Controller {

	@Override
	public Navigation run() throws Exception {

		response.setContentType("text/html;charset=UTF-8");

		Validators v = new Validators(request);
		v.add("wiki", RequiredValidator.INSTANCE);
		if (!v.validate()) {
			return null;
		}

		String wiki = asString("wiki");
		response.getWriter().print(WikiUtil.toHtml(wiki));
		response.flushBuffer();

		System.out.println(WikiUtil.toHtml(wiki));

		return null;
	}
}
